#include "basewidget.h"

BaseShowWidget::BaseShowWidget(BaseShowWidget *parent) : QLabel(parent)
{
    setAlignment(Qt::AlignCenter);
    setWordWrap(true);
}

void BaseShowWidget::setSelected()
{
    //首先通知全局观察者有点击事件，散发消息给注册的人实现别的控件取消选中
    GlobalObserver::getGlobalObserver()->notify(loss_select_msg);

    if (!m_select)
        m_select = true;
    setSelectStyle(m_select);
}

//setAttribute(Qt::WA_TransparentForMouseEvents)可以忽略子控件的点击事件
void BaseShowWidget::mousePressEvent(QMouseEvent *event)
{
    if (event->button() == Qt::LeftButton)
    {
        setSelected();
    } else
    {
        QWidget::mousePressEvent(event);
    }
}

void BaseShowWidget::setLossSelect()
{
    m_select = false;
    setSelectStyle(m_select);
}

